package utils
{
	import flash.utils.getQualifiedClassName;
	
	import mx.utils.ObjectUtil;

	public class ObjectUtil
	{
		/**
		 * 合并对象属性（对象类型必须为Object）
		 * @param p_objA
		 * @param p_objB
		 * @return
		 */
		public static function mergeObject(p_mainObject:Object, p_joinObject:Object):Object
		{
			if(p_mainObject == null)
				return p_joinObject;
			if(p_joinObject == null)
				return p_mainObject;
			if(getQualifiedClassName(p_mainObject) != "Object" || 
				getQualifiedClassName(p_joinObject) != "Object")
				return p_mainObject;
			var nObj:Object = mx.utils.ObjectUtil.copy(p_mainObject);
			for(var i:String in p_joinObject){
				if(nObj.hasOwnProperty(i))
					nObj[i] = mergeObject(p_mainObject[i], p_joinObject[i]);
				else
					nObj[i] = p_joinObject[i];
			}
			return nObj;
		}
	}
}